export const POSITION_MAP: any = {
  bottomLeft: {
    originX: 'start',
    originY: 'bottom',
    overlayX: 'start',
    overlayY: 'top',
    offsetX: 0,
    offsetY: -1,
  },
  topLeft: {
    originX: 'start',
    originY: 'top',
    overlayX: 'start',
    overlayY: 'bottom',
    offsetX: 0,
    offsetY: 1,
  },
};

export const ADJUST_POSITION_MAP = [POSITION_MAP.bottomLeft, POSITION_MAP.topLeft];

export function getPosition(connectedPosition): string | undefined {
  const keyList = ['originX', 'originY', 'overlayX', 'overlayY', 'offsetX', 'offsetY'];
  const positionKeys = Object.keys(POSITION_MAP);
  for (const position of positionKeys) {
    if (keyList.every((key): boolean => connectedPosition[key] === POSITION_MAP[position][key])) {
      return position;
    }
  }
  return undefined;
}
